package com.dkts.oil.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.dkts.oil.config.OilConfig;
import com.dkts.oil.converter.GeometryConverter;
import com.dkts.oil.converter.OilAddressConverter;
import com.dkts.oil.converter.OilAddressV2Converter;
import com.dkts.oil.converter.WriterToFile;
import com.dkts.oil.util.GeoAreaUtil;
import com.dkts.oil.web.vo.request.SiteSelectionRequest;
import com.dkts.oil.web.vo.response.AddressPlanResponse;
import lombok.extern.slf4j.Slf4j;
import org.locationtech.jts.geom.Geometry;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  储备库选址实现类
 * </p>
 *
 * @author heguanglong
 * @since 2025-04-10
 */
@Service
@Slf4j
public class OilAddressV2ServiceImpl {
    @Autowired
    private OilConfig config;

    @Autowired
    private OilAddressV2Converter oilAddressV2Converter;

    @Autowired
    private AddressPlanV2ServiceImpl addressPlanV2Service;

    @Autowired
    AddressPlanV3ServiceImpl addressPlanV3Service;
    public List<AddressPlanResponse.PlanItem> oilStorageV2(SiteSelectionRequest request) throws Exception {
        return oilStorageV2New(request);
    }

    public List<AddressPlanResponse> oilStorageV3(SiteSelectionRequest request) throws Exception {
        Geometry planGeometry = OilAddressV2Helper.getArearGeometry(request, config);
        List<Geometry> obstacles = oilAddressV2Converter.listObstacles(planGeometry, request, false);
        if (obstacles != null && obstacles.size() > 0){

        }
        return new ArrayList<>();
    }

    public List<AddressPlanResponse.PlanItem> oilStorageV2New(SiteSelectionRequest request) throws Exception {
        //总的规划区域
        Geometry planGeometry = OilAddressV2Helper.getArearGeometry(request, config);
        //在总的规划区域不能规划的区域
        List<Geometry> obstacles = oilAddressV2Converter.listObstacles(planGeometry, request,false);

            //List<Geometry> wcgxzxBuild = oilAddressV2Converter.listObstacles(request.getDefaultPolygon(), request,true);

        //请帮我规划出油库的面积（转运站 储备库 消耗库 外场供油中心面积） 的多个油库方案
        return addressPlanV3Service.oilStorageV3(request,planGeometry,obstacles);
    }
}
